﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Profile;
using System.Data;
using System.Web.Security;

namespace WebSite.cn
{
    public partial class userinfo : BasePage
    {
        // Fields
        public string membermsg = "";

        // Methods
        private void Bind()
        {
            DataTable table = SQLAccess.GreatDs("select * from DB_Member where memberid=" + this.Session["memberid"] + "").Tables[0];
            if (table.Rows.Count > 0)
            {
                string sSex = "";
                if (table.Rows[0]["sex"].ToString() == "0")
                {
                    sSex = "男";
                }
                else if (table.Rows[0]["sex"].ToString() == "1")
                {
                    sSex = "女";
                }
                else
                {
                    sSex = "";
                }
                this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>登录用户名：</td>";
                this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["memberlogin"].ToString() + "</td></tr>";
                this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>收件人姓名：</td>";
                this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["membername"].ToString() + "</td></tr>";
               // this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>性别：</td>";
               // this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + sSex + "</td></tr>";
                this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>手机：</td>";
                this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["phone"].ToString() + "</td></tr>";
                this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>联系电话：</td>";
                this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["tel1"].ToString() + "</td></tr>";
               // this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>邮政编码：</td>";
               // this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["post"].ToString() + "</td></tr>";
                this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>联系地址：</td>";
                this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["address"].ToString() + "</td></tr>";
               // this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>QQ：</td>";
               // this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["qq"].ToString() + "</td></tr>";
              //  this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>MSN：</td>";
               // this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["msn"].ToString() + "</td></tr>";
                this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>E-Mail：</td>";
                this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["email"].ToString() + "</td></tr>";
               // this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>级别：</td>";
               // this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["rankid"].ToString() + "</td></tr>";
                //this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>积分：</td>";
                //this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["score1"].ToString() + "</td></tr>";
                //this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>总购物额：</td>";
                //this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["xinprice"].ToString() + "</td></tr>";
                //this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>总使用积分：</td>";
                //this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["memberlogin"].ToString() + "</td></tr>";
                //this.membermsg = this.membermsg + "<tr><td width='25%' height='28' align='right' bgcolor='#FFFFFF'>总支付积分：</td>";
                //this.membermsg = this.membermsg + "<td align='left' bgcolor='#FFFFFF'> 　" + table.Rows[0]["memberlogin"].ToString() + "</td></tr>";
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!base.IsPostBack)
            {
                if ((this.Session["username"] != null) && (this.Session["memberid"] != null))
                {
                    this.Bind();
                }
                else if (base.Request.QueryString["action"] != null)
                {
                    if (base.Request.QueryString["action"] == "login")
                    {
                        if (string.Compare(base.Request.Form["lvalidate"].ToUpper(), Session["checkCode"].ToString().ToUpper()) != 0)
                            {
                                Response.Write("<script>alert('验证码不正确！请重新输入！');window.location.href='login.aspx';</script>");
                                return;
                            }
                      
                        if (((base.Request.Form["luser"] != null) && (base.Request.Form["lpas"] != null)) && ((base.Request.Form["luser"] != "") && (base.Request.Form["lpas"] != "")))
                        {
                            DataTable table = SQLAccess.GreatDs("select * from DB_Member where memberlogin='" + re.replace(base.Request.Form["luser"]) + "' and memberpwd='" + FormsAuthentication.HashPasswordForStoringInConfigFile(re.replace(base.Request.Form["lpas"]), "MD5") + "'").Tables[0];
                            if (table.Rows.Count > 0)
                            {
                                //UserCardCodeList = null;

                                if (WebSite.login.usercenter(re.replace(base.Request.Form["luser"]), FormsAuthentication.HashPasswordForStoringInConfigFile(re.replace(base.Request.Form["lpas"]), "MD5"), "0"))
                                {
                                    HttpContext.Current.Response.Write("<script language=javascript>window.location.href='userinfo.aspx';</script>");
                                }
                                else
                                {
                                    base.Response.Write("<script language=javascript>alert('用户名或密码输入有误!');window.location.href='userinfo.aspx';</script>");
                                    base.Response.End();
                                }
                            }
                            else
                            {
                                base.Response.Write("<script language=javascript>alert('用户名或密码输入有误!');window.location.href='login.aspx';</script>");
                                base.Response.End();
                            }
                        }
                        else
                        {
                            base.Response.Write("<script language=javascript>alert('用户名和密码不能为空!');window.location.href='login.aspx';</script>");
                            base.Response.End();
                        }
                    }
                }
                else
                {
                    base.Response.Write("<script language=javascript>window.location.href='index.aspx';</script>");
                    base.Response.End();
                }
            }
        }

       

    }
}